var t = getApp();
var template = require('../../../../template/backstageTemplate.js');
Page({
  data: {
    _num: 2,
    text: "未认证",
    showshow: !1,
    wrapBox: !0,
    nameText: "",
    wzshow: !1,
    wzshow1: !0,
    forbidden: !0,
    stateset: [{
        "title": '拒绝接单',
        "tip": '休息中拒绝所有患者问诊'
      }, {
        "title": '工作中',
        "tip": '工作中可接受患者问诊'
      },

    ],
    stateindex: 0,
    ispopup: false,
    xieyi: false,
  },
  // 开方记录
  kaifangjilu(e) {
    console.log("开方记录", e)
    wx.navigateTo({
      url: '/hyb_yl/zhuanjiasubpages/pages/chufangjilu/chufangjilu?zid=' + wx.getStorageSync('zid'),
    })
  },
  gohome: function () {
    wx.reLaunch({
      url: '/hyb_yl/tabBar/index/index',
    })
  },
  // 资金中心
  zijin: function () {
    wx.navigateTo({
      url: '/hyb_yl/mysubpages/pages/capitacenter/capitacenter?zid=' + wx.getStorageSync('zid'),
    })
  },
  server: function () {
    wx.navigateTo({
      url: '/hyb_yl/mysubpages/pages/openservice/openservice?zid=' + wx.getStorageSync('zid'),
    })
  },
  stateset: function (e) {
    var index = e.currentTarget.dataset.dex;
    var that = this;
    that.setData({
      stateindex: index,
      ispopup: false
    })
    t.util.request({
      'url': "entry/wxapp/zhuanjia.stateset",
      data: {
        zid: wx.getStorageSync('zid'),
        openid: wx.getStorageSync('openid'),
        status: index
      },
      success: function () {
        that.Images();
        that.getMyzhuan();
        that.getMymoney()
        t.util.request({
          'url': 'entry/wxapp/studio.ifzhuanjia',
          data: {
            openid: wx.getStorageSync('openid')
          },
          success: function (res) {
            console.log(res)
            var zid = res.data.zid
            that.setData({
              info: res.data,
              total_money: res.data.shouyi
            })
          },
          fail: function (err) {
            console.log(err)
          },
        })
      }
    })
  },
  statesetshow: function () {
    this.setData({
      ispopup: true
    })
  },
  closepopup: function () {
    this.setData({
      ispopup: false
    })
  },
  nkset: function () {
    wx.navigateTo({
      url: '/hyb_yl/zhuanjiasubpages/pages/cover/cover?zid=' + wx.getStorageSync('zid'),
    })
  },
  editdata: function () {
    var that = this
    var zid = that.data.zid
    wx.navigateTo({
      url: '/hyb_yl/backstageOther/pages/myRenZheng/myRenZheng?zid=' + zid,
    })
  },
  // 查看评价列表
  pingjia: function () {
    var that = this
    var zid = that.data.zid
    wx.navigateTo({
      url: '/hyb_yl/czhuanjiasubpages/pages/estimate/estimate?zid=' + zid,
    })
  },
  // 查看签约记录
  qianyue: function () {
    var that = this;
    var zid = that.data.zid;
    wx.navigateTo({
      url: '/hyb_yl/mysubpages/pages/patientman/patientman?state=1&zid=' + zid,
    })
  },
  lodinserweis: function () {
    var that = this
    var zid = that.data.zid
    //生成二维码
    t.util.request({
      'url': 'entry/wxapp/Docerweima',
      data: {
        zid: zid,
      },
      success: function (res) {
        console.log(res)
        var weweima = res.data.data.weweima
        var info = JSON.stringify(res.data.data)
        wx.navigateTo({
          url: '/hyb_yl/backstageLifes/pages/dialysis/dialysis?info= ' + info + '&weweima=' + weweima,
        })
      },
    })

  },

  sign: function (a) {
    var e = wx.getStorageSync("log") || "",
      s = this;
    wx.request({
      url: t.globalData.dic + "doctor/arrive/doctorSignin/" + e + "/1/4",
      success: function (a) {
        if (200 == a.data.code) {
          s.setData({
            wzshow: !0,
            wzshow1: !1
          }), console.log(a.data.data), console.log(a.data.data.getIntegral), wx.showToast({
            title: "签到成功，恭喜你获得" + a.data.data.getIntegral + "积分",
            icon: "none",
            duration: 3e3
          });
          var e = wx.getStorageSync("log") || "";
          wx.request({
            url: t.globalData.dic + "doctor/personal/info/get/" + e,
            data: {},
            success: function (t) {
              s.setData({
                arr: t.data.data
              });
            }
          });
        }
      }
    });
  },
  signs: function (t) {
    wx.showToast({
      title: "您已签到",
      icon: "none",
      duration: 3e3
    });
  },
  alet: function (t) {
    this.setData({
      showshow: !1
    });
  },
  wrapBox: function (t) {
    this.setData({
      showshow: !0
    });
  },
  onLoad: function (options) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var that = this
    this.Images();
    this.getMyzhuan();
    this.getMymoney()
    template.tabbar("tabBar", 3, this)
    t.util.request({
      'url': 'entry/wxapp/studio.ifzhuanjia',
      data: {
        openid: wx.getStorageSync('openid')
      },
      success: function (res) {
        console.log(res)
        var zid = res.data.zid
        var total_money = res.data.shouyi
        that.updocmoney(zid, total_money)
      },
      fail: function (err) {
        console.log(err)
      },
    })
    t.util.request({
      'url': 'entry/wxapp/index.base',
      success: function (res) {
        that.setData({
          baseinfo: res.data,
        })
      },
      fail: function (err) {
        console.log(err)
      },
    })
  },
  radioChange() {
    this.setData({
      xieyi: true
    })
  },
  closezhe: function () {
    this.setData({
      xieyi: false
    })
  },
  onShow: function (a) {

    var that = this
    let pages = getCurrentPages();
    let currPage = pages[pages.length - 1];
    if (currPage.data.state == 1) {
      that.getMymoney()
    }
    t.util.request({
      'url': 'entry/wxapp/studio.ifzhuanjia',
      data: {
        openid: wx.getStorageSync('openid')
      },
      success: function (res) {
        console.log(res)
        var zid = res.data.zid
        var total_money = res.data.shouyi
        that.updocmoney(zid, total_money)
      },
      fail: function (err) {
        console.log(err)
      },
    })
  },
  RenZheng: function (t) {
    var zid = t.currentTarget.dataset.zid
    console.log(t)
    wx.navigateTo({
      url: "/hyb_yl/backstageOther/pages/myRenZheng/myRenZheng?zid=" + zid
    });
  },
  wrap: function (t) {
    this.setData({
      hidehide: !0
    });
  },
  Images: function (a) {
    var e = this;

  },
  getMyzhuan: function () {
    var that = this
    t.util.request({
      'url': 'entry/wxapp/studio.ifzhuanjia',
      data: {
        openid: wx.getStorageSync('openid')
      },
      success: function (res) {
        console.log(res)
        that.setData({
          zhuanjiaImg: res.data.z_thumbs,
          zid: res.data.zid,
          zhuanjia: res.data,
          z_yy_sheng: res.data.exa
        })
      },
      fail: function (err) {
        console.log(err)
      },
    })
  },

  getMymoney: function () {
    // var that = this
    // var openid = wx.getStorageSync('openid')
    // t.util.request({
    //   'url': 'entry/wxapp/Doctormoney',
    //   data: {
    //     openid: openid
    //   },
    //   success: function (res) {
    //     console.log(res)
    //     that.setData({
    //       zhuanmoney: res.data.data.overmoney,
    //       num: res.data.data.overmoney
    //     })
    //   },
    //   fail: function (err) {
    //     console.log(err)
    //   },

    // })
  },
  //总收益
  zongClick: function (e) {
    var that = this
    var docmoney = e.currentTarget.dataset.docmoney
    var z_name = e.currentTarget.dataset.z_name
    var zid = that.data.zid
    //查询收益明细
    // t.util.request({
    //   'url': 'entry/wxapp/Zhuanjshouymx',
    //   data: {
    //     zid: zid
    //   },
    //   success: function (res) {
    //     console.log(res)
    //     var record = JSON.stringify(res.data)
    //     wx.navigateTo({
    //       url: '/hyb_yl/backstageLifes/pages/mn/mn?record=' + record + '&zid=' + zid + '&docmoney=' + docmoney + '&z_name=' + z_name,
    //     })
    //   }
    // })
  },
  mo_money(e) {
    var that = this
    var advertisement = that.data.info.advertisement;
    var sfzimgurl1back = that.data.info.sfzimgurl1back;
    var sfzimgurl2back = that.data.info.sfzimgurl2back;
    var zgzimgurl1back = that.data.info.zgzimgurl1back;
    var zmoney = parseFloat(e.currentTarget.dataset.zmoney)
    var zid = e.currentTarget.dataset.zid
    console.log('1' + advertisement, '2' + sfzimgurl1back, '3' + sfzimgurl2back, '4' + zgzimgurl1back)

    if (advertisement == '' || sfzimgurl1back == '' || sfzimgurl2back == '' || zgzimgurl1back == '') {
      wx.showModal({
        title: '提示',
        content: "请先完善信息",
        success: function (con) {
          if (con.confirm) {
            wx.navigateTo({
              url: '/hyb_yl/backstageOther/pages/myRenZheng/myRenZheng?zid=' + zid,
            })
          }
        }
      })
    } else {
      wx.navigateTo({
        url: '/hyb_yl/twosubpages/pages/my_ti/my_ti?zmoney=' + zmoney + '&zid=' + zid,
      })
    }


  },
  updocmoney(zid, total_money) {
    var that = this
    var zid = zid
    var total_money = total_money
    //更新专家金额
    t.util.request({
      'url': 'entry/wxapp/zhuanjia.uptotalmoney',
      data: {
        zid: zid,
        total_money: total_money
      },
      success: function (res) {
        console.log(res)
        t.util.request({
          'url': 'entry/wxapp/studio.ifzhuanjia',
          data: {
            openid: wx.getStorageSync('openid')
          },
          success: function (res) {
            that.setData({
              zid: zid,
              info: res.data,
              total_money: res.data.total_money
            })
          },
          fail: function (err) {
            console.log(err)
          },
        })
      }
    })
  },
  set_jurisdiction: function () {
    wx.navigateTo({
      url: '/hyb_yl/zhuanjiasubpages/pages/set_jurisdiction/set_jurisdiction?zid=' + wx.getStorageSync('zid'),
    })
  },
});